#pragma once

#include <vector>
#include <string>

#include "scr_resource.h"

class SCRResourceManager;

struct SCRCell
{
	SCRCell()
		: m_Top(0)
		, m_Left(0)
		, m_Width(0)
		, m_Height(0)
	{
	}

	int m_Top;
	int m_Left;
	int m_Width;
	int m_Height;
};

struct SCRFrame
{
	struct Cell
	{
		Cell()
			: m_OffsetX(0)
			, m_OffsetY(0)
			, m_CellIdx(0) 
		{
		}

		int m_OffsetX;
		int m_OffsetY;
		int m_CellIdx;
	};

	SCRFrame()
		: m_OffsetX(0)
		, m_OffsetY(0)
	{
	}

	int m_OffsetX;
	int m_OffsetY;
	std::vector<Cell> m_Cells;
};

struct SCRAnimation
{
	struct Frame
	{
		Frame()
			: m_Time(0)
			, m_FrameIdx(0)
		{
		}

		int m_Time;
		int m_FrameIdx;
	};

	SCRAnimation()
		: m_TotalTime(0)
	{
	}

	int m_TotalTime;
	std::vector<Frame> m_Frames;
};

class SCRSprite
	: public SCRResource
{
public:

	virtual ~SCRSprite();
	void DrawCell(const int& Index, const int& X, const int& Y);
	void DrawFrame(const int& Index, const int& X, const int& Y);
	void DrawAnimation(const int& Index, const int& X, const int& Y, const int& Time);

	friend class SCRResourceManager;

private:

	SCRSprite(const std::string& Filename); 

	std::vector<SCRCell> m_Cells;
	std::vector<SCRFrame> m_Frames;
	std::vector<SCRAnimation> m_Animations;
};
